/**
 * 
 */
package org.jackysoft.controller;

import java.io.StringWriter;

import javax.annotation.Resource;

import org.jackysoft.controller.base.AbstractController;
import org.jackysoft.entity.HtmlFormTemplate;
import org.jackysoft.service.HtmlTemplateService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author qujiakang
 * 
 */

@Controller
@RequestMapping("/formtemplate")
public class FormTemplateController extends AbstractController<HtmlFormTemplate> {

	
	@Resource
	private HtmlTemplateService service;

	@RequestMapping(value="/update/{id}",method=RequestMethod.POST)
	public void updatecontent(@PathVariable String id,String content) throws Exception {
		service.update(id, content);
		
	}

	@RequestMapping("/preview/{id}")
	public void preview(@PathVariable String id,@ModelAttribute String content) throws Exception {
		  StringWriter sw  = service.loadToWriter(id);
	      content = sw.toString();
	}

}